package cz.cuni.amis.episodic.bayes.memories;

import cz.cuni.amis.episodic.dybanem.DBN;
import cz.cuni.amis.episodic.dybanem.Evidence;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;

/**
 * 
 * @author ik
 */
@RequiredArgsConstructor
@Data
public class MemoryElement implements Evidence {
   
	final String node;
   //double[] distribution;
   final int from, to;
   
   @NonNull
   Double surprise;

   final String outcome;
   
   /**
    * Nanoseconds to compute this mem. -1 means that it is uninitialized.
    */
    long timeNanoToCompute = -1;
   
    @Override
    public void setEvidence(DBN dbn) {
        for (int i = from; i <= to; i++) {
            dbn.setDBNEvidence(node, i, outcome);
        }
    }

    @Override
    public void clearEvidence(DBN dbn) {
        dbn.clearDBNEvidence(node, from, to);
    }  
    
    public void markInKLGraph(double[] kl) {
        for (int i = from; i <= to; i++) {
            kl[i] = Double.NaN;
        }
    }
}
